<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>



<div id="header">
<div class="background">
<h1><a href="index.html">DelliStore</a></h1>
<ul class="sf-menu sf-navbar">
	<li class="active"><a href="index.action">主页</a></li>
	<s:iterator value="naviList" var="n">
		<s:if test="%{#n.parentKey == ''}">
			<li><a href="<s:property value="#n.url" />"><s:property
				value="#n.displayName" /></a> <s:if test="%{#n.type == 'parentRoot'}">
				<ul>
					<s:iterator value="naviList" var="l">
						<s:if test="%{#l.parentKey == #n.keyString}">
							<li><a href="<s:property value="#l.url" />"><s:property
								value="#l.displayName" /></a></li>
						</s:if>
					</s:iterator>
				</ul>
			</s:if></li>
		</s:if>
	</s:iterator>
</ul>
<div class="house">
<div class="house_top"></div>
<div class="house_body">
<div class="house_leftbox">商品key<input type="text" id="test_key"
	value="1" /><br />
商品name<input type="text" id="test_name" value="2" /><br />
商品price<input type="text" id="test_price" value="3" /><br />
<a href="#" onclick="add_one_test();return false">添加此商品</a><br />

<input type="text" id="test_cookies" value="3" /><a href="#"
	onclick="set_cartcookies();return false">设置此cookies</a><br />

<a href="#" onclick="show_cartcookies();return false">显示cookies</a> <a
	href="#" onclick="delete_cartcookies();return false">清空cookies</a> <a
	href="#" onclick="load_cookies();return false">load cookies</a> <a
	href="#" onclick="show_cartlist();return false">显示 list</a> <a href="#"
	onclick="">显示cookies</a></div>
<div class="house_blackboard">
<div class="blackboard_content">
<div class="cart_info">你的购物车共有3种商品 总价：999.9元</div>

<div class="cart_list">
<ul>
	<li>
	<div class="cart_one_li">
	<div class="cart_one_name">非常非常好吃的绝味鸭脖（500g）</div>
	<a class="cart_one_delete" href="#" onclick="return false">删</a></div>
	<div class="cart_one_li"><span>数量：</span><a href="#" onclick="return false">加</a><a
		href="#" onclick="return false">减</a><div class="cart_one_num">11</div>
		<span>价格：</span>
		<div class="cart_one_price">11</div><span>元</span>
	</div>
	</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
	<li>非常非常好吃的绝味鸭脖（500g）</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<script type="text/javascript">

// initialise plugins
jQuery(function() {
	jQuery('ul.sf-menu').superfish( {
		pathClass : 'current'
	});

});

var goods_list;
var goods_key_list;
var goods_name_list;
var goods_price_list;
var goods_num_list;

function load_cookies() {
	var old_info = $.cookie("cxpin_cart");
	if ( null === old_info ) {
		//cookies为空
		return;
	}
	goods_list = old_info.split("&");
	var sum ="sum:\n";
	goods_key_list	= new Array();
	goods_name_list	= new Array();
	goods_price_list	= new Array();
	goods_num_list	= new Array();
	for (i=0; i<goods_list.length-1; i++) {
		var tmp = goods_list[i].split("^");
		goods_key_list[i] = tmp[0];
		goods_name_list[i] = tmp[1];
		goods_price_list[i] = tmp[2];
		goods_num_list[i] = tmp[3];
	}
};

function show_cartlist() {
	var sum ="sum:\n";
	for (i=0; i<goods_list.length-1; i++) {
		sum += i + "\tkey:" + goods_key_list[i] 
			+"\tname:" + goods_name_list[i] 
			+ "\tprice:" + goods_price_list[i] 
			+ "\tnum:" + goods_num_list[i] + "\n";
	}
	alert(sum);
};

function add_one_test() {
	cookies_add_one_goods($("#test_key").val(), $("#test_name").val(), $("#test_price").val());
};

function cookies_add_one_goods ( key, name, price) {
	var old_info = $.cookie("cxpin_cart");
	if ( null === old_info ) {
		old_info = "";
	}
	var new_info = old_info + key
					+ "^" + name + "^" + price
					+ "^" + "1" + "&";
	$.cookie("cxpin_cart", new_info );
};

function show_cartcookies() {
	alert( $.cookie("cxpin_cart") );
};

function set_cartcookies() {
	$.cookie("cxpin_cart", $("#test_cookies").val() );
};

function delete_cartcookies() {
	$.cookie("cxpin_cart", null );
	alert( "清空成功！──" + $.cookie("cxpin_cart") );
};
</script>
